<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Document</title>
    <jsp:include page="/WEB-INF/include/base.jsp"></jsp:include>

    <link rel="stylesheet" href="static/css/minireset.css"/>
    <link rel="stylesheet" href="static/css/common.css"/>
    <link rel="stylesheet" href="static/css/cart.css"/>
    <link rel="stylesheet" href="static/css/bookManger.css"/>

    <script type="text/javascript">
        $(function () {
            $(".del").click(function () {
                /*if(!confirm("确认删除吗？")){
                  return false;
                }*/
                return confirm("确认删除吗？")
            });
        });
    </script>
</head>
<body>
<div class="header">
    <div class="w">
        <div class="header-left">
            <a href="index.jsp">
                <img src="static/img/logo.gif" alt=""
                /></a>
            <h1>图书管理系统</h1>
        </div>
        <jsp:include page="/WEB-INF/include/manager_head.jsp"></jsp:include>
    </div>
</div>
<div class="list">
    <div class="w">
        <div class="add">
            <a href="pages/manager/book_add.jsp">添加图书</a>
        </div>
        <table>
            <thead>
            <tr>
                <th>图片</th>
                <th>商品名称</th>
                <th>价格</th>
                <th>作者</th>
                <th>销量</th>
                <th>库存</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${requestScope.page.list}" var="book">
                <tr>
                    <td>
                        <img src="${pageScope.book.imgPath}" alt=""/>
                    </td>
                    <td>${pageScope.book.title}</td>
                    <td>${pageScope.book.price}</td>
                    <td>${pageScope.book.author}</td>
                    <td>${pageScope.book.sales}</td>
                    <td>${pageScope.book.stock}</td>
                    <td>
                        <a href="BookManagerServlet?method=getBookById&bookId=${pageScope.book.id}">修改</a>
                        <a href="BookManagerServlet?method=deleteBook&bookId=${pageScope.book.id}" class="del">删除</a>
                    </td>
                </tr>
            </c:forEach>

            </tr>
            </tbody>
        </table>
        <div class="footer">
            <div class="footer-right">
                <c:if test="${requestScope.page.pageNo != 1}">
                    <div>
                        <a href="BookManagerServlet?method=getPage&pageNo=1">首页</a>
                    </div>
                    <div>
                        <a href="BookManagerServlet?method=getPage&pageNo=${requestScope.page.pageNo-1}">上一页</a>
                    </div>
                </c:if>
                <c:choose>
                    <c:when test="${requestScope.page.totalPage<5}">
                        <c:set var="begin" value="1"></c:set>
                        <c:set var="end" value="${requestScope.page.totalPage}"></c:set>
                    </c:when>
                    <c:when test="${requestScope.page.pageNo<=3}">
                        <c:set var="begin" value="1"></c:set>
                        <c:set var="end" value="5"></c:set>
                    </c:when>
                    <c:otherwise>
                        <c:set var="begin" value="${requestScope.page.pageNo-2}"></c:set>
                        <c:set var="end" value="${requestScope.page.pageNo+2}"></c:set>
                        <c:if test="${pageScope.end>requestScope.page.totalPage}">
                            <c:set var="begin" value="${requestScope.page.totalPage-4}"></c:set>
                            <c:set var="end" value="${requestScope.page.totalPage}"></c:set>
                        </c:if>
                    </c:otherwise>
                </c:choose>
                <ul>
                    <c:forEach begin="${pageScope.begin}" end="${pageScope.end}" var="num">
                        <c:if test="${requestScope.page.pageNo == pageScope.num}">
                            <li class="active">
                                <a href="BookManagerServlet?method=getPage&pageNo=${pageScope.num}">${pageScope.num}</a>
                            </li>
                        </c:if>
                        <c:if test="${requestScope.page.pageNo != pageScope.num}">
                            <li>
                                <a href="BookManagerServlet?method=getPage&pageNo=${pageScope.num}">${pageScope.num}</a>
                            </li>
                        </c:if>
                    </c:forEach>
                </ul>
                <c:if test="${requestScope.page.pageNo != requestScope.page.totalPage}">
                    <div>
                        <a href="BookManagerServlet?method=getPage&pageNo=${requestScope.page.pageNo+1}">下一页</a>
                    </div>
                    <div>
                        <a href="BookManagerServlet?method=getPage&pageNo=${requestScope.page.totalPage}">末页</a>
                    </div>
                </c:if>
                <span>共${requestScope.page.totalPage}页</span>
                <span>${requestScope.page.count}条记录</span>
                <span>到第</span>
                <input type="text" id="pageNo" />
                <span>页</span>
                <button id="btnId">确定</button>
                <script type="text/javascript">
                    $(function () {
                        $("#btnId").click(function () {
                            var pageNo = $("#pageNo").val();
                            location = "BookManagerServlet?method=getPage&pageNo="+pageNo;
                        });
                    });
                </script>
            </div>
        </div>
    </div>
</div>
<div class="bottom">
    <div class="w">
        <div class="top">
            <ul>
                <li>
                    <a href="">
                        <img src="static/img/bottom1.png" alt=""/>
                        <span>大咖级讲师亲自授课</span>
                    </a>
                </li>
                <li>
                    <a href="">
                        <img src="static/img/bottom.png" alt=""/>
                        <span>课程为学员成长持续赋能</span>
                    </a>
                </li>
                <li>
                    <a href="">
                        <img src="static/img/bottom2.png" alt=""/>
                        <span>学员真是情况大公开</span>
                    </a>
                </li>
            </ul>
        </div>
        <div class="content">
            <dl>
                <dt>关于尚硅谷</dt>
                <dd>教育理念</dd>
                <!-- <dd>名师团队</dd>
                <dd>学员心声</dd> -->
            </dl>
            <dl>
                <dt>资源下载</dt>
                <dd>视频下载</dd>
                <!-- <dd>资料下载</dd>
                <dd>工具下载</dd> -->
            </dl>
            <dl>
                <dt>加入我们</dt>
                <dd>招聘岗位</dd>
                <!-- <dd>岗位介绍</dd>
                <dd>招贤纳师</dd> -->
            </dl>
            <dl>
                <dt>联系我们</dt>
                <dd>http://www.atguigu.com</dd>
                <dd></dd>
            </dl>
        </div>
    </div>
    <div class="down">
        尚硅谷书城.Copyright ©2015
    </div>
</div>
</body>
</html>
